package com.qingneng.budget.web;

import java.util.List;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.Action;
import com.qingneng.budget.service.sdk.IWorkBudgetService;
import com.qingneng.budget.util.BaseAction;
import com.qingneng.budget.vo.BudgetQuantitiesBuildItem;
import com.qingneng.budget.vo.QantitiesBuildItem;

public class LoadQuantitesItemAction extends BaseAction{
	
	private static final Logger logger = Logger.getLogger(LoadQuantitesItemAction.class);
	
	private int project_workinfo_id;
	
	public int getProject_workinfo_id() {
		return project_workinfo_id;
	}
	public void setProject_workinfo_id(int project_workinfo_id) {
		this.project_workinfo_id = project_workinfo_id;
	}

	private List rows = null;
	
	private Integer total;
	
	public List getRows() {
		return rows;
	}
	public void setRows(List rows) {
		this.rows = rows;
	}
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
	}

	public IWorkBudgetService workBudgetService;
	
	public LoadQuantitesItemAction(){
		
	}
	public LoadQuantitesItemAction(IWorkBudgetService workBudgetService){
		this.workBudgetService = workBudgetService;
	}
	
	public String execute(){
		// 判断是否已经保存工程量
		logger.info("工程id-project_workinfo_id:"+project_workinfo_id);
		
		BudgetQuantitiesBuildItem bean =  new BudgetQuantitiesBuildItem();
		bean.setProject_workinfo_id(project_workinfo_id);
		logger.info("+++开始获取工程量建筑类型结果+++");
		List list = workBudgetService.getBudgetQuantitiesBuildItem(bean);
		if(list!=null && list.size()>0){
			logger.info("LoadQuantitesItemAction :工程id-project_workinfo_id:"+project_workinfo_id+"：有工程量建筑类型结果");
			rows = list;
			total = new Integer(1000);
		}else{
			logger.info("LoadBudgetItemAction:工程id-project_workinfo_id:"+project_workinfo_id+"：无预算表结果，获取预算项模板");
			QantitiesBuildItem item = new QantitiesBuildItem();
			rows = workBudgetService.getBuildItem(item);
			total = new Integer(1000);
		}
	
	
		
		return Action.SUCCESS;
	}

}
